<meta charset="utf-8"/>
<div class="row">
  <div class="col-xs-12">
    <div class="row">
      <div class="col-xs-12">
        <div style="height:36px;margin-top:2px">
          <table class="no-border" style="display:inline">
            <tr>
              <td permission='goods_btn_listData' style="padding-right:6px;display:none">
                商品名称
              </td>
              <td permission='goods_btn_listData' style="display:none">
                <input type="text" id="key_contract_name" class="form-control search-query" placeholder="输入商品名称" style="width:140px"/>
              </td>
              <td permission='goods_btn_listData' style="padding:0 6px;display:none" class="hidden-480">
                商品状态
              </td>
              <td permission='goods_btn_listData' style="display:none" class="hidden-480">
                <span class="input-group-btn">
                  <button data-toggle="dropdown" class="btn btn-primary btn-white dropdown-toggle col-sm-12" style="margin-left:0px;">
                    <span id="labelSearch_valid">选择状态</span>
                    <i class="ace-icon fa fa-angle-down"></i>
                  </button>
                  <ul class="dropdown-menu col-sm-12" style="width:99px;min-width:99px;">
                    <li>
                      <a href="javascript:winFn.dropdown('#key_valid','','#labelSearch_valid','选择状态');">选择状态</a>
                    </li>
                    <li>
                      <a href="javascript:winFn.dropdown('#key_valid','1','#labelSearch_valid','未下架');">未下架</a>
                    </li>
                    <li>
                      <a href="javascript:winFn.dropdown('#key_valid','2','#labelSearch_valid','已下架');">已下架</a>
                    </li>
                  </ul>
                  <input id="key_valid" type="hidden"/>
                </span>
              </td>
              <td permission='goods_btn_listData' style="display:none">
                <div class="input-group">
                  <span class="input-group-btn"><button type="button" class="btn btn-inverse btn-white" id="btnSearch" title="搜索查询"><span class="ace-icon fa fa-search bigger-110"></span>搜索</button></span>
                </div>
              </td>
              <td permission='goods_btn_add' style="display:none">
                <div class="input-group">
                  <span class="input-group-btn"><button type="button" class="btn btn-inverse btn-white" id="btnAdd" title="新增|添加"><span class="ace-icon fa fa-plus bigger-110"></span>添加</button></span>
                </div>
              </td>
            </tr>
          </table>
          <div class="hidden-480 pull-right tableTools-container" permission='goods_btn_listData' style="display:none;margin-bottom:2px"></div>
        </div>
        <table id="tableListGoods" class="table table-striped table-bordered table-hover">
          <tbody>
          <tr>
            <td style="text-align:center;height:37px">正在加载……</td>
          </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
<div id="div_goods_edit" style="display:none;padding-top:2px">
  <form class="form-horizontal" id="form_goods_edit" role="form">
    <label class="col-sm-2 control-label no-padding-right"><div class="hr-4">商品名称<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-9">
      <div class="hr-4"></div>
      <input type="text" id="contract_name" placeholder="商品名称" class="form-control" maxlength="64" title="商品名称"/>
    </div>
    <label class="col-sm-2 control-label no-padding-right"><div class="hr-4">商品类型<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-9">
      <div class="hr-4"></div>
      <div class="input-group" title="选择商品类型">
        <span class="input-group-btn">
          <button data-toggle="dropdown" class="btn btn-primary btn-white dropdown-toggle col-sm-12" style="margin-left:0px">
            <span id="labelDynamic_contract_type">选择商品类型</span>
            <i class="ace-icon fa fa-angle-down"></i>
          </button>
          <ul class="dropdown-menu col-sm-12" id="ulDynamic_contract_type"></ul>
          <input id="contract_type" maxlength="19" type="hidden"/>
        </span>
      </div>
    </div>
    <label class="col-sm-2 control-label no-padding-right"><div class="hr-4">商品缩略图<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-9" id="thumbnail_parent" >
      <div class="hr-4"></div>
      <input type="file" id="thumbnail" placeholder="商品缩略图" class="form-control" title="请选择商品缩略图"/>
    </div>
    <label class="col-sm-2 control-label no-padding-right"><div class="hr-4">商品价格<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-9">
      <div class="hr-4"></div>
      <input type="text" id="price" placeholder="商品价格" class="form-control" maxlength="12" oninput="value=value.replace(/[^\d.]/g,'')" title="商品价格"/>
    </div>
    <label class="col-sm-2 control-label no-padding-right"><div class="hr-4">每件瓶数<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-9">
      <div class="hr-4"></div>
      <input type="text" id="bottles" placeholder="设定按件售卖时商品每件包含多少瓶" class="form-control" maxlength="10" title="设定按件售卖时商品每件包含多少瓶" oninput="value=value.replace(/[^\d]/g,'')"/>
    </div>
    <label class="col-sm-2 control-label no-padding-right"><div class="hr-4">优惠券数量<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-9">
      <div class="hr-4"></div>
      <input type="text" id="coupon" placeholder="设定全国默认的优惠券数量" class="form-control" maxlength="10" title="设定全国默认的优惠券数量" oninput="value=value.replace(/[^\d]/g,'')"/>
    </div>
    <label class="col-sm-2 control-label no-padding-right"><div class="hr-4">商品描述<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-9" style="margin-bottom:6px">
      <div class="hr-4"></div>
      <textarea id="details" placeholder="商品描述" class="form-control limited" maxlength="921600000" style="width:100%;height:550px;" title="请输入商品描述"></textarea>
    </div>
  </form>
</div>
<div id="div_goods_valid" style="display:none;padding-top:2px">
  <label class="col-sm-2 control-label no-padding-right"><div class="hr-4">商品状态<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
  <div class="col-sm-9">
    <div class="hr-4"></div>
    <div class="input-group" title="选择状态">
        <span class="input-group-btn">
          <button data-toggle="dropdown" class="btn btn-primary btn-white dropdown-toggle col-sm-12" style="margin-left:0px;">
            <span id="dropdownLabel_valid">选择状态</span>
            <i class="ace-icon fa fa-angle-down"></i>
          </button>
          <ul class="dropdown-menu col-sm-12">
            <li>
              <a id="valid_" href="javascript:winFn.dropdown('#valid','','#dropdownLabel_valid','选择状态');">选择状态</a>
            </li>
            <li>
              <a id="valid1" href="javascript:winFn.dropdown('#valid','1','#dropdownLabel_valid','已下架');">已下架</a>
            </li>
            <li>
              <a id="valid2" href="javascript:winFn.dropdown('#valid','2','#dropdownLabel_valid','未下架');">未下架</a>
            </li>
          </ul>
          <input id="valid" maxlength="1" type="hidden"/>
        </span>
    </div>
  </div>
</div>
<div id="divKeyColumns" style="display:none;padding:1px 0px;"></div>
<div style="display:none;">
  <input type="hidden" id="goods_btn_listData"/>
  <input type="hidden" id="goods_btn_add"/>
  <input type="hidden" id="goods_row_edit"/>
  <input type="hidden" id="goods_row_queryById"/>
  <input type="hidden" id="goods_row_delById"/>
  <input type="hidden" id="goods_btn_contract_type"/>
</div>
<div id="div_proxy_integral" style="display:none;padding-top:6px">
  <form class="form-horizontal" role="form">
    <table>
      <tbody>
        <tr>
          <td style="padding-left:4px">省分公司佣金</td>
          <td style="padding-left:4px"><input type="text" id="level_value1" placeholder="省分公司佣金数" value="0" class="form-control"  maxlength="12" oninput="value=value.replace(/[^\d.]/g,'')" title="省分公司佣金数"/></td>
          <td style="padding-left:4px;padding-right:4px">省分公司广告推广费</td>
          <td style="padding-right:4px"><input type="text" id="level_securitie1" placeholder="省分公司广告推广费" value="0" class="form-control"  maxlength="12" oninput="value=value.replace(/[^\d.]/g,'')" title="省分公司广告推广费"/></td>
        </tr>
        <tr>
          <td colspan="4" style="height:2px"></td>
        </tr>
        <tr>
          <td style="padding-left:4px;">市分公司佣金</td>
          <td style="padding-left:4px"><input type="text" id="level_value2" placeholder="市分公司佣金数" value="0" class="form-control"  maxlength="12" oninput="value=value.replace(/[^\d.]/g,'')" title="市分公司佣金数"/></td>
          <td style="padding-left:4px;padding-right:4px">市分公司广告推广费</td>
          <td style="padding-right:4px"><input type="text" id="level_securitie2" placeholder="市分公司广告推广费" value="0" class="form-control"  maxlength="12" oninput="value=value.replace(/[^\d.]/g,'')" title="市分公司广告推广费"/></td>
        </tr>
        <tr>
          <td colspan="4" style="height:2px"></td>
        </tr>
        <tr>
          <td style="padding-left:4px">区级代理利润</td>
          <td style="padding-left:4px"><input type="text" id="level_value3" placeholder="区级代理利润数" value="0" class="form-control"  maxlength="12" oninput="value=value.replace(/[^\d.]/g,'')" title="区级代理利润数"/></td>
          <td style="padding-left:4px;padding-right:4px">区级代理广告推广费</td>
          <td style="padding-right:4px"><input type="text" id="level_securitie3" placeholder="区级代理广告推广费" value="0" class="form-control"  maxlength="12" oninput="value=value.replace(/[^\d.]/g,'')" title="区级代理广告推广费"/></td>
        </tr>
        <tr>
          <td colspan="4" style="height:2px"></td>
        </tr>
        <tr>
          <td style="padding-left:4px">直营门店利润</td>
          <td style="padding-left:4px"><input type="text" id="level_value4" placeholder="直营门店利润数" value="0" class="form-control"  maxlength="12" oninput="value=value.replace(/[^\d.]/g,'')" title="直营门店利润数"/></td>
          <td style="padding-left:4px;padding-right:4px">直营门店广告推广费</td>
          <td style="padding-right:4px"><input type="text" id="level_securitie4" placeholder="直营门店广告推广费" value="0" class="form-control"  maxlength="12" oninput="value=value.replace(/[^\d.]/g,'')" title="直营门店广告推广费"/></td>
        </tr>
        <tr>
          <td colspan="4" style="height:2px"></td>
        </tr>
        <tr>
          <td style="padding-left:4px" class="text-right">推 荐 人 积 分</td>
          <td style="padding-left:4px;padding-right:4px" colspan="3"><input type="text" id="level_value5" placeholder="设置推荐积分" value="0" class="form-control"  maxlength="12" oninput="value=value.replace(/[^\d.]/g,'')" title="设置推荐积分"/></td>
        </tr>
      </tbody>
    </table>
  </form>
</div>
<script type="text/javascript">
  ;(function($){
    var tableDom = '#tableListGoods';
    var urlRoute = '/goods/';/*请求controller层的url*/
    var getList = urlRoute + 'listData';/*获取数据列表*/
    var urlAdd = urlRoute + 'add';/*添加*/
    var urlEdit = urlRoute + 'edit';/*编辑*/
    var urlQueryById = urlRoute + 'queryById';/*根据id查询对应的数据*/
    var urlDelById = urlRoute + 'delById';/*根据id删除对应的数据*/
    var getContract_type = urlRoute + 'getContract_type';/*获取字段contract_type的下拉框列动态值选项的数据*/
    var getEditIntegral = urlRoute + 'editIntegral';/*获取字段contract_type的下拉框列动态值选项的数据*/
    var stateOriginal = {};//仅供参考，更新优化-选项1,可参考项目law-frontend的页面serviceAd.html和后端law-backend的ServiceADService.java;记录编辑的值,仅在编辑时可用
    var thisTable = null;
    thisPage = {
      init : function(){
        this.initTable();
        this.createDropdown();
        this.initDom();
        this.addEvent();
      },
      initDom : function(){
        winFn.initFileShoose('#thumbnail',['jpg','JPG','jpeg','JPEG','png','PNG','svg','SVG'],'请选择商品缩略图');
      },
      createDropdown: function(){
        //获取字段contract_type的下拉框列动态值选项的数据
        layerFn.ajaxGetResult(getContract_type,{},function(data){
          if(AppKey.code.code200 == data.code){
            winFn.initDropdown(data.data,'#ulDynamic_contract_type','#contract_type','#labelDynamic_contract_type','选择商品类型');
          }else{
            winFn.initDropdown([],'#ulDynamic_contract_type','#contract_type','#labelDynamic_contract_type',data.msg);
          }
        });
      },
      addEvent: function(){
        $(tableDom +' tbody').on('dblclick','td:not(:first-child,:last-child)',function(){//除去每行的第一个和最后一个单元格均可双击事件
          if(verifyFn.inputRequired('#goods_row_edit')){
            return;
          }
          thisPage.trDblclick(thisTable.row($(this).parent()).data());
        });
        $('#btnAdd').on('click', function(){
          thisPage.edit();
        });
        //搜索按钮
        $('#btnSearch').on('click', function(){
          thisPage.search();
        });
        //重置按钮
        //按钮组-自定义显示列
        $('#iconColumn').parent().parent().on('click', function(){
          pageDataTable.columnCustom(thisTable, tableDom,'#divKeyColumns');
        });
        //按钮组-搜索
        $('#iconRefresh').parent().parent().on('click', function(){
          thisPage.search();
        });
      },
      /**获取已选中的主键集合,用法:var kids = thisPage.getKeyIds();if(kids == null){layerFn.alert('请选择要操作的数据', AppKey.code.code199);return;}*/
      getKeyIds : function(){
        var arrays = thisTable.rows({selected : true}).data();//获取已勾选的数据行
        if(arrays.length == 0){
          return null;
        }
        var kids = '';
        for(var i = 0; i < arrays.length; i++){
          var value = arrays[i].kid;
          if(value != ''){
            if(kids.length > 0) kids += ",";
            kids += value;
          }
        }
        return kids;
      },
      initTable : function(){
        var optsVisible = getOptsVisible('goods_row');//确定是否要显示操作选项
        var aoColumns = [];
        aoColumns.push({
          data : "contract_name",
          sortable : false,
          title : "商品名称"
        });
        aoColumns.push({
          data : "goodsType",
          sortable : false,
          title : "商品类型"
        });
        aoColumns.push({
          data : "thumbnail",
          sortable : false,
          title : "商品缩略图",
          width : "80px",
          class : 'hidden-480 text-center',
          render : function(value,type,row,meta){
            var objs = eval('(' + value + ')') || {};
            if(objs.urlFile){
              var filePath = webFiles + objs.urlFile;
              return '<div style="position:relative"><a href="javascript:;" onclick="window.open(\''+filePath+'\',\'_blank\').location" onmouseover="$(\'#img_'+row.kid+'\').css(\'display\',\'\');" onmouseout="$(\'#img_'+row.kid+'\').css(\'display\',\'none\');" title="点击查看原图">查看</a><img id="img_'+row.kid+'" src="'+filePath+'" style="position:absolute;margin-top:16px;display:none;width:350px;height:300px;z-index:6"/></div>';
            }else{
              return '暂无';
            }
          }
        });
        aoColumns.push({
          data : "price",
          sortable : false,
          width : "80px",
          class : 'text-center',
          title : "商品价格"
        });
        aoColumns.push({
          data : "valid",
          sortable : false,
          title : "销售状态",
          width : "80px",
          className : 'hidden-480 text-center',
          render : function(value,type,row,meta){
            if(value){
              switch (value){
                case 1:
                  return "未下架";
                case 2:
                  return "已下架";
                default:
                  return "";
              }
            }else{
              return "";
            }
          }
        });
        aoColumns.push({
          data : "deleted",
          sortable : false,
          title : "显示状态",
          class : 'text-center',
          width : "80px",
          render : function(value,type,row,meta){
            if(value){
              switch (value){
                case 0:
                  return "隐藏";
                case 1:
                  return "显示";
                default:
                  return "";
              }
            }else{
              return "";
            }
          }
        });
        aoColumns.push({
          data : "bottles",
          sortable : false,
          width : "80px",
          class : 'text-center',
          title : "每件瓶数"
        });
        aoColumns.push({
          data : "coupon",
          sortable : false,
          width : "80px",
          class : 'text-center',
          title : "优惠券数量",
          render : function(value,type,row,meta){
            switch (value){
              case 0:
                return "0";
              default:
                return value;
            }
          }
        });
        aoColumns.push({
          data : "add_date",
          sortable : true,
          title : "发布时间",
          class : 'text-center',
          width : "124px",
          render : function(value){
            if(value){
              return winFn.formatDate(value,true);/*宽度width: "121px",*/
            }else{
              return "";
            }
          }
        });
        aoColumns.push({
          data : "details",
          sortable : false,
          title : "商品描述",
          class : 'text-center',
          width : "76px",
          render : function(value,type,row,meta){
            var len = value.length;
            if(len > 30){
              return "<a href='javascript:thisPage.rowColumnDetails("+meta.row+",\"details\",1);'>查看描述</a>";
            }else{
              return value;
            }
          }
        });
        if(optsVisible){
          aoColumns.push({
            data : "_kid_",
            width : "100px",
            title : "<label style='color:#000;margin-left:6px;' title='单行操作'>操作选项</label>",/*此处的字‘操作选项’请勿修改,此处的文字还有其它用途*/
            sortable : false
          });
        }
        var columnDefs = [];
        if(optsVisible){//是否来显示某列
          columnDefs.push({
            targets : -1,
            render : function(value,type,row,meta){
              return "<a title='编辑|修改' href='javascript:thisPage.rowEdit("+ meta.row +");' style='outline:none;text-decoration: none;color:#3b8cff;margin-left:4px;display:none' permission='goods_row_edit'>编辑</a><a title='设置商品推广或交易后的积分数' href='javascript:thisPage.rowIntegral("+ meta.row +");' style='outline:none;text-decoration: none;color:#f1690e;margin-left:4px;display:none' permission='goods_row_edit'>积分</a><a title='删除当前行数据' class='hidden-480' href='javascript:thisPage.rowDel("+ meta.row +");' style='outline:none;text-decoration: none;color:#f00;margin-left:4px;display:none' permission='goods_row_delById'>删除</a>";
            }
          });
        }
        columnDefs.push({
          targets : [0,1,2,3,4,5,6,7,8,9],
          render : function(value,type,row,meta){
            return pageDataTable.formatColumn(value);
          }
        });
        columnDefs.push({
          visible : false,//列的隐藏显示
          targets : []//指定列索引
        });
        thisTable = pageDataTable.initDataTable({
          tableDom : tableDom,
          sAjaxSource : getList,
          fnServerParams : function(params){
            params.push(
              {"name":"contract_name","value":winFn.getDomValue('#key_contract_name')},
              {"name":"valid","value":winFn.getDomValue('#key_valid')}
            );
          },
          aoColumns : aoColumns,
          columnDefs : columnDefs,
          complete : function(settings,data){},
          selected : function(selected){}
        });
        pageDataTable.buttons(thisTable);
        pageDataTable.action(thisTable);
        pageDataTable.select(thisTable, tableDom);
        pageDataTable.tooltip();
        $('.dataTables_scroll .dataTables_scrollBody').removeAttr('style');//解决dataTable表头下拉框被tbody遮挡
      },
      //双击事件
      trDblclick: function(data){
        if(data){
          thisPage.edit(data.kid);
        }
      },
      search: function(){
        if(verifyFn.inputCheck('#goods_btn_listData','没有操作权限')) return;
        $(tableDom + '_wrapper table input[type=checkbox]').prop('checked',false);
        thisTable.draw();
      },
      resetForm: function(){
        winFn.clearFormData('#form_goods_edit',[{'dropdownLabel_contract_type':'选择商品类型'},{'dropdownLabel_valid':'选择下架状态'}]);
      },
      edit: function(kid){
        var title = '添加';
        if(kid != null && kid.length > 0){
          if(verifyFn.inputCheck('#goods_row_queryById','没有操作权限')) return;
          title = '编辑';
          layerFn.queryByIdHint(urlQueryById, kid, function(data){
            thisPage.openDialog(title, kid, data);
            //thisPage.editJson(data.data,['ad_img']);//仅在赋值后再执行此代码,更新优化-选项2
          });
        }else{
          thisPage.openDialog(title);
        }
      },
      //移除不需要对比的key(此方法可有可无)
      editJson : function(data,keys){
        if(keys){
          for(var h = 0; h < keys.length; h++){
            delete data[keys[h]];//删除key元素
          }
        }
        stateOriginal = data;
      },
      //对比是否已修改了值,仅需判断必填的字段，文件上传的字段单独处理
      filterValue : function(params){
        if(stateOriginal != null){
          var ignoreKeys = '';
          var requiredKeys = '';
          for(var so in stateOriginal){
            if(params[so] == stateOriginal[so]){
              delete params[so];
              if(ignoreKeys != ''){
                ignoreKeys += ','+so;
              }else{
                ignoreKeys += so;
              }
            }else{
              if(requiredKeys != ''){
                requiredKeys += ','+so;
              }else{
                requiredKeys += so;
              }
            }
          }
          if(ignoreKeys != ''){
            params['ignoreKeys'] = ignoreKeys;//记录后端忽略验证的key以,隔开的字符串,注意数据库字段是否允许为空,可参考项目law-backend的joins.html;law-backend的JoinsService的方法edit();
          }
          if(requiredKeys != ''){
            params['requiredKeys'] = requiredKeys;//记录后端必填验证的key以,隔开的字符串
          }
        }
      },
      openDialog: function(title, kid, map){
        var url = urlAdd;
        if(kid != null && kid.length > 0){
          url = urlEdit;
          if(verifyFn.inputNull('#goods_row_edit','没有编辑权限')) return;
        }else{
          if(verifyFn.inputNull('#goods_btn_add','没有添加权限')) return;
        }
        layerFn.winKindEditor(title,'#div_goods_edit',['#details'],(map == null ? null : map.data), ['966px','560px'], function(layerIndex, layero){
          if(verifyFn.inputEmpty('#contract_name'))return;
          if(kid == null || kid.length <= 0){
            if(verifyFn.inputNull('#contract_type','请选择商品类型')) return;
            if(verifyFn.inputNull('#thumbnail','请选择商品缩略图文件')) return;
          }
          if(verifyFn.inputEmpty('#price'))return;
          if(verifyFn.inputEmpty('#bottles'))return;
          if(verifyFn.inputEmpty('#coupon'))return;
          if(verifyFn.inputNull('#details','商品描述不能为空')) return;
          var params = {
            contract_name : winFn.getDomValue('#contract_name',true),
            contract_type : winFn.getDomValue('#contract_type',true),
            details : winFn.getDomValue('#details'),
            price : winFn.getDomValue('#price',true),
            valid : winFn.getDomValue('#valid',true),
            bottles : winFn.getDomValue('#bottles',true),
            coupon : winFn.getDomValue('#coupon',true),
            kid : kid
          };
          var formData = new FormData();
          for(var key in params){
            formData.append(key,params[key]);
          }
          var file_thumbnail = document.getElementById("thumbnail").files[0];
          if(file_thumbnail){
            var mb = file_thumbnail.size / (1024 * 1024);//得到的MB,做文件大小限制
            if(mb > 3){
              layerFn.alert('商品缩略图已超过３ＭＢ',AppKey.code.code199);
              return;
            }
            formData.append("thumbnail",file_thumbnail);
          }else{
            formData.append("thumbnail",null);
          }
          layerFn.formSubmit(url,formData,function(data){
            thisPage.complete(data,layerIndex,true);
          });
        });
        thisPage.resetForm();
        if(map != null){
          $.each(map.data,function(k,v){
            try{
              if(k == 'contract_type'){
                winFn.editDropdown('#labelDynamic_contract_type', v);
                $('#' + k).val(v);
                return true;
              }
              if(k == 'temp_thumbnail'){//保留,占位符,若使用到则删除前缀temp_即可
                //var jsonThumbnail = eval('(' + k + ')');文件上传字段类型为json类型
                //$('#thumbnail').attr('rel',v);//a标签,保留
                return true;
              }
              if(k == 'valid'){
                winFn.editDropdown('#dropdownLabel_valid','valid' + v);
                return true;
              }
              $('#' + k).val(v);//若是有问题则把这个放在最前面
            }catch(e){}
          });
        }
      },
      rowIntegral : function(rowIndex){
        for(var i=1;i<6;i++){
          $('#level_value'+i).val('0');
          $('#level_securities'+i).val('0');
        }
        var row = thisTable.row(rowIndex).data();
        layerFn.addOrEdit('['+row.contract_name+']设置商品的佣金和积分','#div_proxy_integral',['550px','274px'],function(layerIndex,layero){
          var params = {
            kid : row.kid,
            value1 : winFn.getDomValue('#level_value1',true),
            value2 : winFn.getDomValue('#level_value2',true),
            value3 : winFn.getDomValue('#level_value3',true),
            value4 : winFn.getDomValue('#level_value4',true),
            value5 : winFn.getDomValue('#level_value5',true),
            securitie1 : winFn.getDomValue('#level_securitie1',true),
            securitie2 : winFn.getDomValue('#level_securitie2',true),
            securitie3 : winFn.getDomValue('#level_securitie3',true),
            securitie4 : winFn.getDomValue('#level_securitie4',true)
          };
          layerFn.submit(getEditIntegral,params,function(data){
            thisPage.complete(data,layerIndex,true);
          });
        });
        var level_values = row.level_values;
        var scores = row.scores;
        var securities = row.securities;
        if(level_values){
          var tempVal = level_values.split('_Www_Fwt_Cloud_');
          var tempScores = scores.split('_Www_Fwt_Cloud_');
          var tempSecurities = securities.split('_Www_Fwt_Cloud_');
          for(var w=0;w<tempVal.length;w++){
            var tempLevel = tempVal[w];
            $('#level_value'+tempLevel).val(tempScores[w]);
            $('#level_securitie'+tempLevel).val(tempSecurities[w]);
          }
        }
      },
      rowEdit : function(rowIndex){
        var row = thisTable.row(rowIndex).data();
        thisPage.edit(row.kid);
      },
      rowDel : function(rowIndex){
        if(verifyFn.inputCheck('#goods_row_delById','没有删除操作权限')) return;
        var row = thisTable.row(rowIndex).data();
        layerFn.confirm('删除后无法恢复,确定要删除吗?', function(){
          layerFn.delByIdHint(urlDelById, row.kid,function(data){
            thisPage.complete(data,null,true);
          });
        });
      },
      /*column指定列名,type:1是普通的文本;2json对象;3是json对象里含json对象;*/
      rowColumnDetails : function(rowIndex,column,type){
        var row = thisTable.row(rowIndex).data();
        switch (type){
          case 1:
            layerFn.viewValue(row[column],'600px');
            break;
          case 2:
            if(row[column] != undefined){
              window.open(webFiles+row[column],'_blank').location;
            }else{
              layerFn.alert('暂无数据',AppKey.code.code199);
            }
            break;
          case 3:
            thisPage.createHtml(row[column],column,'originalName');//json里含json
            break;
          default:
            break;
        }
      },
      //查看隐藏部分是全部内容,用法 render : function(value,type,row,meta){return thisPage.rowColumnView(value);}
      rowColumnView : function(value){
        if(value == null || value == undefined) return '';
        if(typeof value === "string"){
          //value = value.replace(/</g, '&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');
        }
        var len = value.length;
        if(len > 30){
          return "<a href='javascript:layerFn.viewValue(\""+value+"\",\"430px\");' title='点击查看详情' style='outline:none;text-decoration: none;'>"+value.substring(0,30)+"…</a>";
        }else{
          return value;
        }
      },
      complete: function(data,index,search){
        try{
          if(index){
            layerFn.closeIndex(index);
          }
          if(search){
            thisPage.search();
          }
          if(data){
            layerFn.handleResult(data.msg,data.code);
          }
        }catch(e){}
      }
    };
    thisPage.init();
    $('script').remove();
  })(jQuery);
</script>